#ifndef RESIZERBUTTONSTRATEGY_H
#define RESIZERBUTTONSTRATEGY_H


#ifdef _WIN32
	#pragma once
#endif


#include "../../ToolkitLayer.h"
#include "DraggingResizerStrategy.h"
#include <IBuffer/IBuffer.h>


/**
 * This strategy extends the DraggingResizerStrategy by adding a invisible
 * button on the bottom right corner of the component bounds. It uses a button
 * buffer to determine the active area of resizing. When the component is
 * clicked over the area labeled as the resizing button in the button buffer,
 * the component can be resized by dragging. When the component is released,
 * the buffer dimensions are updated with the new component dimensions.
 *
 * @author Fabricio Anastacio - fabriciocfa@yahoo.com
 * @since August 9, 2007
 */
class TOOLKITLAYER_API ResizerButtonStrategy : public DraggingResizerStrategy
{
	// Attributes
protected:
	/** Button buffer type identifier. */
	unsigned int buttonBufferType;

	// BUTTON BUFFER VALUES
	/** No button value. */
	unsigned char noButtonValue;
	/** Movable area button value. */
	unsigned char movableAreaButtonValue;
	/** Resize area button value. */
	unsigned char resizeButtonValue;


	// Methods
public:
	/**
	 * Constructs a resizer button strategy.
	 */
	ResizerButtonStrategy(void);
	/**
	 * Destroys this strategy.
	 */
	~ResizerButtonStrategy(void);


protected:
	/**
	 * Initializes the properties (i. e., i-buffers) of the associated
	 * component.
	 */
	void initProperties();
	/**
	 * Handles the given event.
	 *
	 * @param evt the event to be handled.
	 */
	void onEvent(LargeDisplayEvent* evt);
	/**
	 * Defines the strategy to be used when the associated component is
	 * resized.
	 *
	 * @param width the new width of the component.
	 * @param height the new height of the component.
	 */
	void resize(unsigned int width, unsigned int height);
	

private:
	// BUTTON BUFFER
	/**
	 * Returns the value of the current active button buffer of the associated
	 * component at the given global coordinates. If there is no button buffer
	 * currently active for the associated component or the coordinates are not
	 * inside the buffer, a constant value for NO_BUTTON is returned.
	 *
	 * @param x the x global coordinate to be checked.
	 * @param y the y global coordinate to be checked.
	 * @return the value retrieved from the button buffer or
	 * a constant value for NO_BUTTON in case of failure.
	 */
	unsigned char getButtonValue(unsigned int x, unsigned int y);
	/**
	 * Fills the active button buffer with the default values.
	 * @param buffer the button buffer to be filled.
	 */
	void fillButtonBuffer(IBuffer<unsigned char>* buffer);
};

#endif // RESIZERBUTTONSTRATEGY_H
